package com.example.administrator.x3picturetransliteration.Home.Presenter.Activity;

import android.app.Activity;
import android.content.Context;

import com.example.administrator.x3picturetransliteration.Base.BasePresenter;
import com.example.administrator.x3picturetransliteration.Base.HttpGo;
import com.example.administrator.x3picturetransliteration.Bean.HttpDataBean;

import java.util.Map;

import rx.subscriptions.CompositeSubscription;

/**
 * 安全管理
 * Created by Administrator on 2019/9/11.
 */

public class SecurityManagementPresenter extends BasePresenter{

    public SecurityManagementPresenter(Context context, CompositeSubscription mCompositeSubscription) {
        super(context, mCompositeSubscription);
    }

    /** 重置绑定密码短信 */
    public void sendResetSmsCode(Map<String,String> httpdata, final Callback mCallback){

        mCompositeSubscription.add(

                mHttpGo.postSubscription("sms_code/sendResetSmsCode", httpdata, new HttpGo.HttpGoCallback() {
                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(HttpDataBean httpDataBean) {

                        if (httpDataBean.getCode()==0){

                            mCallback.getData(null);
                        }
                    }
                })
        );
    }

    /** 重置密码 */
    public void resetPassword(Map<String,String> httpdata){

        mCompositeSubscription.add(

                mHttpGo.postSubscription("user/resetPassword", httpdata, "修改成功",new HttpGo.HttpGoCallback() {
                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(HttpDataBean httpDataBean) {

                        if (httpDataBean.getCode()==0)((Activity)context).finish();
                    }
                })
        );

    }

}
